<template>
  <div class="titleBox">
    <span>{{ titleName }}</span>
    <div class="topLeft">{{ compInfo.compName }}</div>
    <div class="timeDiv">{{ time[1] }} {{ time[0] }}</div>
  </div>
</template>
<script>
import { getCurrentDate } from "@/utils/function";
export default {
  components: {},
  props: {
    compInfo: {
      type: Object,
      default: {},
    },
    titleName: {
      type: String,
      default: {},
    },
  },
  data() {
    return {
      time: getCurrentDate(),
      timeInterval: () => {},
    };
  },
  watch: {},
  mounted() {
    this.startInterval();
  },
  beforeDestroy() {
    clearInterval(this.timeInterval);
  },
  methods: {
    async startInterval() {
      /** 开启时间定时器 */
      this.timeInterval = setInterval(() => {
        this.time = getCurrentDate();
      }, 1000);
    },
  },
};
</script>
<style lang="scss" scoped>
.titleBox {
  height: 70px;
  background: url(../../../assets/images/topBg.png) no-repeat;
  background-size: 100% 100%;
  border-bottom: 1px solid #162c52;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  span {
    color: #fff;
    font-weight: bold;
    font-size: 1.8rem;
    letter-spacing: 0.1em;
    background: linear-gradient(to bottom, #f5f5f5, #1eb6fe); /* 从左到右渐变 */
    -webkit-background-clip: text; /* Safari/Chrome支持该属性 */
    color: transparent; /* 将文本颜色设置为透明 */
  }
  .timeDiv {
    position: absolute;
    left: 40px;
    top: 20px;
    color: #fff;
    font-weight: bold;
    font-size: 1rem;
  }
  .topLeft {
    position: absolute;
    right: 40px;
    top: 10px;
    color: #fff;
    font-weight: bold;
    font-size: 1rem;
    // background: url(../../../assets/images/titBg.png) no-repeat;
    background-size: 100% 100%;
    height: 35px;
    line-height: 35px;
    padding: 0 15px;
  }
  .refresh {
    width: 80px;
    position: absolute;
    right: 30px;
    top: 20px;
    text-align: right;
    color: #fff;
    cursor: pointer;
    font-weight: bold;
    font-size: 1rem;
  }
}
</style>
<style lang="scss"></style>
